package com.alienlab.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import sun.launcher.resources.launcher;

public class httpPostGet {
public static void main(String[] args) throws IOException {
	
	
	
	
	
	
	
	
	
	
	
	
	
    try {
        //查询今天日期的报纸
    	/*String url = "https://leancloud.cn:443/1.1/classes/news_pdf?where=%7B%22news_time%22%3A%222016-06%2F05%22%7D&&&order=news_no&&";*/
    	String url = "https://leancloud.cn:443/1.1/classes/tb_news?order=news_no&&";
        URL restServiceURL = new URL(url);
        HttpURLConnection httpConnection = (HttpURLConnection) restServiceURL.openConnection();
        httpConnection.setRequestMethod("GET");
        httpConnection.setRequestProperty("Content-Type", "application/json");
        httpConnection.setRequestProperty("X-LC-Id", "04tA7v3k4qyxjytIPrXDULgq-gzGzoHsz");
        httpConnection.setRequestProperty("X-LC-Key", "laSjFrKQD7Bvf991kvcD8Sps");

        if (httpConnection.getResponseCode() != 200) {
               throw new RuntimeException("HTTP GET Request Failed with Error code : "
                             + httpConnection.getResponseCode());
        }

        BufferedReader responseBuffer = new BufferedReader(new InputStreamReader(
               (httpConnection.getInputStream())));

        String output;
        while ((output = responseBuffer.readLine()) != null) {
        	//得到所有报纸的信息

        }

        httpConnection.disconnect();

   } catch (MalformedURLException e) {

        e.printStackTrace();

   } catch (IOException e) {

        e.printStackTrace();

   }

 }
}
